package NetWork;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Vector;

import javax.sql.rowset.CachedRowSet;

import Global.DDBQuery;
import Global.TransObject;

public class ResultSetScheduler extends StringScheduler
{

	public static Queue<CachedRowSet> resultSetQueue= new LinkedList<CachedRowSet>();
	public ResultSetScheduler(String host, int port,Queue<TransObject> queue)
	{
		super(host, port, queue);
	}

	public void stopThread()
	{
		keepAlive = false;
	}

	public void run()
	{
		CachedRowSet crs = null;
		while (keepAlive)
		{
			TransObject transObject = transObjectQueue.poll();
			if (transObject != null)
			{
				crs = (CachedRowSet)(transObject.obj);
				resultSetQueue.add(crs);
				Vector<NetWorkDelegate> vector = TransmissionUtil.delegateVector;
				for (NetWorkDelegate d : vector)
				{
					d.didReceiveResultSet(transObject.siteType,hostsString, portNum, crs);
				}
			}
			else
			{
				try
				{
					sleep(100);
				}
				catch (InterruptedException e)
				{
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		
	}
}
